package io.renren.controller;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.SbydglDetEntity;
import io.renren.service.SbydglDetService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 异动管理明细
 * 
 * @author zhangheng
 * @email zh_123shmily@163.com
 * @date 2017-08-03 15:03:42
 */
@RestController
@RequestMapping("sbydgldet")
public class SbydglDetController extends AbstractController{
	@Autowired
	private SbydglDetService sbydglDetService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<SbydglDetEntity> sbydglDetList = sbydglDetService.queryList(query);
		int total = sbydglDetService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(sbydglDetList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{yddetId}")
	public R info(@PathVariable("yddetId") Integer yddetId){
		SbydglDetEntity sbydglDet = sbydglDetService.queryObject(yddetId);
		
		return R.ok().put("sbydglDet", sbydglDet);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	public R save(@RequestBody SbydglDetEntity sbydglDet){
		sbydglDetService.save(sbydglDet,getUser());
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	public R update(@RequestBody SbydglDetEntity sbydglDet){
		sbydglDetService.update(sbydglDet);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody Integer[] yddetIds){
		sbydglDetService.deleteBatch(yddetIds);
		
		return R.ok();
	}
	/**
	 * 审核
	 */
	@RequestMapping("/simpleaudit")
	public R simpleAudit(@RequestBody JSONObject params){
		sbydglDetService.simpleAudit(params,getUser());
		return R.ok();
	}

	/**
	 * 审核
	 */
	@RequestMapping("/replace")
	public R replace(@RequestBody JSONObject params){
		sbydglDetService.replace(params,getUser());
		return R.ok();
	}

}
